<template>
  <div>
    <el-tabs
      type="border-card"
      tab-position="left"
      :stretch="false"
      style="height: 81vh"
      v-loading="loading"

    >
      <el-tab-pane >
        <template #label>
          <span class="custom-tabs-label"> 企业注册信息 </span>
        </template>
        <tabsInfo ></tabsInfo>
      </el-tab-pane>
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label"> 用能单位联系人信息 </span> </template
        ><tablesInfo :listId="2" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位能源管理体系信息
          </span> </template
        ><tablesInfo :listId="3" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位能源管理人员信息
          </span> </template
        ><tablesInfo :listId="4" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位能耗监测项目负责人信息
          </span> </template
        ><tablesInfo :listId="5" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位能源计量人员配置信息
          </span> </template
        ><tablesInfo :listId="6" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位企业认证信息
          </span> </template
        ><tablesInfo :listId="7" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位产品结构信息
          </span> </template
        ><tablesInfo :listId="8" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位产值、增加值、销售收入
          </span> </template
        ><tablesInfo :listId="9" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位节能项目信息
          </span> </template
        ><tablesInfo :listId="10" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位能源账号信息表
          </span> </template
        ><tablesInfo :listId="11" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <!-- begin -->
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位非能源产品信息
          </span> </template
        ><tablesInfo :listId="12" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位生产工序信息表
          </span> </template
        ><tablesInfo :listId="13" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位工序单元信息表
          </span> </template
        ><tablesInfo :listId="14" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位重点耗能设备信息表 
          </span> </template
        ><tablesInfo :listId="15" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位数据采集配置项信息表 
          </span> </template
        ><tablesInfo :listId="16" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位数据采集配置项信息表 
          </span> </template
        ><tablesInfo :listId="17" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位计量器具更换记录表  
          </span> </template
        ><tablesInfo :listId="18" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位计量器具验定/校准记录  
          </span> </template
        ><tablesInfo :listId="19" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
      <el-tab-pane :lazy="true">
        <template #label>
          <span class="custom-tabs-label">
            用能单位能源资源计量采集数据表  
          </span> </template
        ><tablesInfo :listId="20" :enterprise-id="proId"></tablesInfo></el-tab-pane
      >
    </el-tabs>
    <enterpriseDialog></enterpriseDialog>
  </div>
</template>

<script setup>
import tabsInfo from "./tabsInfo/index.vue";
import enterpriseDialog from "./selectEnterprise/index.vue";
import tablesInfo from "./tablesInfo/index.vue";
import { getToken } from "@/api/energySystem";
import { ElMessage } from "element-plus";
import mitts from "@/utils/bus.js";
import { ref,onBeforeMount } from "vue";
const token = ref("");
const loading = ref(true);
let datas = [];
const proId = ref("");
/**
 * 开始判断token是否存在或者过期
 */

const getTokenInfo = () => {
  let cookie = getCookie("ssid");
  loading.value = true;
  getToken(datas)
    .then((res) => {
      if (res.status === 200) {
        token.value = res.data;
        document.cookie = "ssid=" + res.data + "; max-age=1200; path=/";
        loading.value = false;
        changeProject();
      } else {
        ElMessage.error("获取token失败,请稍后再试");
      }
    })
    .catch((msg) => {
      //获取出错
      ElMessage.error("获取token失败，请联系管理员！");
    });
};

const getCookie = (name) => {
  let cc = document.cookie.split(";");
  for (let i = 0; i < cc.length; i++) {
    let temp = cc[i].split("=");
    if (temp[0] === name) {
      return temp[1];
    }
  }
  return null;
};
const changeProject = () => {
  let show = true;
  mitts.emit("show", show);
};
onBeforeMount(() => {
  mitts.on("projectId", (e) => {
    proId.value = e;
  });
});
getTokenInfo();
</script>

<style lang="less" scoped>
.custom-tabs-label {
  white-space: pre-wrap;
  text-align: center;
  width: 160px;
}
.el-tabs__nav {
  max-width: 160px;
}
.el-tabs__item {
  padding: 0 5px;
  min-height: 55px;
  font-weight: 600;
}
</style>
